﻿using System;
namespace Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="EN_EhitiseOsaAndmed_query", Namespace="http://producers.ehr.xtee.riik.ee/producer/ehr", Target=typeof(ENEhitiseOsaAndmedQuery))]
    public class ENEhitiseOsaAndmedQuerySerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IENEhitiseOsaAndmedQuery clazz;
        
        public ENEhitiseOsaAndmedQuerySerializer(IENEhitiseOsaAndmedQuery clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.EhosId!=null) {
                Writer.WriteStartElement("ehos_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.EhosId))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "ehos_id")) {
                goto ehos_id;
            }
            else {
                return;
            }
        ehos_id:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_EhitiseOsaAndmed_query>ehos_id");
            }
            clazz.EhosId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ehos_id")).Value;
            goto START;
        }
    }
}
